<template>
  <s-modal
    title="数据"
    :visible="visible"
    width="800px"
    ok-text="保存"
    @cancel="visible = false"
    @ok="save(JSON.parse(JSON.stringify(fakeValue))), (visible = false)"
  >
    <div style="height: 500px">
      <json-viewer v-model="fakeValue" style="height: 480px" />
    </div>
  </s-modal>
</template>
<script>
import JsonViewer from '@/components/JsonViewer/index.vue'
export default {
  name: 'JsonDisplay',
  components: { JsonViewer },
  props: {
    save: {
      type: Function,
      required: false,
      default: () => {}
    }
  },
  data() {
    return {
      visible: false,
      fakeValue: ''
    }
  },
  methods: {
    open(val) {
      this.fakeValue = JSON.parse(JSON.stringify(val))
      this.visible = true
    }
  }
}
</script>
